package com.ttbj.core.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

@Component // 由spring管理
@Lazy(false)
public class ConfigUtils {
	private static Logger log = LoggerFactory.getLogger(ConfigUtils.class);
	private static Configuration configs;
	private static String password;
	private static String urlPath;

	private ConfigUtils() {
		init(null);
	}

	public synchronized static void init(String filePath) {
		/*if (configs != null) {
			return;
		}
		try {
			configs = new PropertiesConfiguration(filePath);
		} catch (ConfigurationException e) {
			e.printStackTrace();
		}

		if (configs == null) {
			throw new IllegalStateException("can`t find file by path:" + filePath);
		}
		password = configs.getString("url_password");
		urlPath = configs.getString("url_path");*/
		log.info(description());
	}

	public static String description() {
		StringBuilder sb = new StringBuilder("---------------------------------------hello,Welcome to rabbit move Operating  System-------------------------");
		return sb.toString();
	}

	public static Configuration getConfigs() {
		return configs;
	}

	public static String getUrlPassword() {
		return password;
	}

	public static String getUrlPath() {
		return urlPath;
	}

}
